﻿using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using XnReader.WinRT.Forms;

// “用户控件”项模板在 http://go.microsoft.com/fwlink/?LinkId=234236 上提供

namespace XnReader.WinRT.Controlx
{
    public sealed partial class Footer : UserControl
    {
        public delegate void HeaderEventHandler(object sender, RoutedEventArgs e);

        public event HeaderEventHandler ListClickEvent;

        public event HeaderEventHandler DeleteClickEvent;

        public event HeaderEventHandler CleanClickEvent;

        public event HeaderEventHandler ModifyClickEvent;

        public Footer()
        {
            InitializeComponent();
        }

        private void BtnClick(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            if (button == null) return;
            switch (button.Name)
            {
                case "btnDelete":
                    {
                        if (DeleteClickEvent != null)
                            DeleteClickEvent(this, e);
                    }
                    break;
                case "btnList":
                    {
                        if (ListClickEvent != null)
                            ListClickEvent(this, e);
                    }
                    break;
                case "btnClean":
                    {
                        if (CleanClickEvent != null)
                            CleanClickEvent(this, e);
                    }
                    break;
                case "btnAbout":
                    {
                        //导航到关于页面
                        var rootFrame = Window.Current.Content as Frame;
                        if (rootFrame != null) rootFrame.Navigate(typeof (About));
                    }
                    break;
                case "btnModify":
                    {
                        if (ModifyClickEvent != null)
                            ModifyClickEvent(this, e);
                    }
                    break;
            }
        }
    }

    public class FooterInfo
    {
        private Visibility _visibleList = Visibility.Collapsed;

        public Visibility VisibleList
        {
            get { return _visibleList; }
            set { _visibleList = value; }
        }

        private Visibility _visibleDelete = Visibility.Collapsed;

        public Visibility VisibleDelete
        {
            get { return _visibleDelete; }
            set { _visibleDelete = value; }
        }

        private Visibility _visibleClean = Visibility.Collapsed;

        public Visibility VisibleClean
        {
            get { return _visibleClean; }
            set { _visibleClean = value; }
        }
        private Visibility _visibleModify = Visibility.Collapsed;

        public Visibility VisibleModify
        {
            get { return _visibleModify; }
            set { _visibleModify = value; }
        }

        private Visibility _visibleAbout = Visibility.Collapsed;

        public Visibility VisibleAbout
        {
            get { return _visibleAbout; }
            set { _visibleAbout = value; }
        }
    }
}
